﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pipes.Queries.Model.Query
{
  public class OrderSpec : Parser.IQueryVisitable
  {
    public IExpression Expr { get; set; }
    public OrderDirection Direction { get; set; }

    public OrderSpec()
    {
      this.Direction = OrderDirection.Ascending;
    }
    public OrderSpec(IExpression expr, OrderDirection dir)
    {
      this.Expr = expr;
      this.Direction = dir;
    }

    public override string ToString()
    {
      return this.Expr.ToString() + (this.Direction == OrderDirection.Descending ? " DESC" : "");
    }

    public void Visit(Parser.IQueryVisitor visitor)
    {
      visitor.Visit(this);
    }
  }
}
